/**
 * Created by benz on 2017/3/19.
 */
module.exports = app => {
    const Sequelize = app.Sequelize;
    return app.model.define('menu', {
        id:{
            type:Sequelize.INTEGER,
            autoIncrement:true,
            allowNull:false,
            primaryKey:true,
            unique:true
        },
        name: {
            type:Sequelize.STRING,
            allowNull:false
        },
        title: {
            type:Sequelize.STRING,
            allowNull:false
        },
        parent: {
            type:Sequelize.INTEGER,
            allowNull:false,
            defaultValue:0
        },
        path: {
            type:Sequelize.STRING,
            allowNull:true
        },
        type: {
            type:Sequelize.INTEGER,
            allowNull:false,
            defaultValue:1,
            commont:"1 普通文章"
        }
    }, {
        timestamps:true,
        paranoid:true,
        underscored: false,
        classMethods: {
            associate() {
                app.model.Menu.hasMany(app.model.Article);
            }
        }
    });
};